import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
public class Test{
    private int a;
    public void swap(Test test){

    }
}
class Solution {
    public int countCompleteSubarrays(int[] nums) {
        Set<Integer> set = new HashSet<>();
        for(int i=0; i<nums.length; i++){
            set.add(nums[i]);
        }
        int count = 0;
        for (int i = 0; i < nums.length; i++) {
            Set<Integer> set1 = new HashSet<>(set);
            for (int j=i; j < nums.length; j++){
                if(set1.contains(nums[j])){
                    set1.remove(nums[j]);
                }
                if(set1.isEmpty()){
                    count++;
                }
            }
        }
        return count;
    }
}

class Solution1 {
    private String join(String a, String b){
        if(a.contains(b)) return a;
        int w = Math.min(a.length(),b.length());
        for(;w>0;w--){
            if(a.endsWith(b.substring(0,w))){
                break;
            }
        }
        return a + b.substring(w);
    }
    public String minimumString(String a, String b, String c) {
        String s1 = join(join(a, b), c);
        String s2 = join(join(a, c), b);
        String s3 = join(join(b, a), c);
        String s4 = join(join(b, c), a);
        String s5 = join(join(c, a), b);
        String s6 = join(join(c, b), a);

        String res = s1;
        for (String str : Arrays.asList(s1, s2, s3, s4, s5, s6)) {
            if (str.length() < res.length()) {
                res = str;
            } else if (str.length() == res.length() && str.compareTo(res) < 0) {
                res = str;
            }
        }
        return res;
    }
}
class Solution2 {
    static class ListNode{
        ListNode next;
        int val;
        public ListNode(int val){
            this.val = val;
        }
    }
    public ListNode deleteDuplication(ListNode pHead) {
        if(pHead == null || pHead.next == null)
            return pHead;
        ListNode nH = new ListNode(0);
        nH.next = pHead;
        ListNode cur = nH;
        while(cur.next != null && cur.next.next != null){
            if(cur.next.val == cur.next.next.val){
                int val = cur.next.val;
                while(cur.next != null && cur.next.val == val){
                    cur.next = cur.next.next;
                }
            }else{
                cur = cur.next;
            }
        }
        return nH.next;
    }
}